package com.directv.z8training.EMS.Entity;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;


/**
 * The persistent class for the "GROUPS" database table.
 * 
 */
@Entity
@Table(name="\"GROUPS\"")
@NamedQuery(name="Group.findAll", query="SELECT g FROM Group g")
public class Group implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private String code;

	private String descirption;

	//bi-directional many-to-one association to GroupRight
	@OneToMany(mappedBy="group")
	private List<GroupRight> groupRights;

	//bi-directional many-to-one association to User
	@OneToMany(mappedBy="group")
	private List<User> users;

	public Group() {
	}

	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getDescirption() {
		return this.descirption;
	}

	public void setDescirption(String descirption) {
		this.descirption = descirption;
	}

	public List<GroupRight> getGroupRights() {
		return this.groupRights;
	}

	public void setGroupRights(List<GroupRight> groupRights) {
		this.groupRights = groupRights;
	}

	public GroupRight addGroupRight(GroupRight groupRight) {
		getGroupRights().add(groupRight);
		groupRight.setGroup(this);

		return groupRight;
	}

	public GroupRight removeGroupRight(GroupRight groupRight) {
		getGroupRights().remove(groupRight);
		groupRight.setGroup(null);

		return groupRight;
	}

	public List<User> getUsers() {
		return this.users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

	public User addUser(User user) {
		getUsers().add(user);
		user.setGroup(this);

		return user;
	}

	public User removeUser(User user) {
		getUsers().remove(user);
		user.setGroup(null);

		return user;
	}

}